package com.peter.smv.utils

import android.content.Context
import android.content.Intent
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.viewbinding.BuildConfig

fun Context.debugToast(msg: String, duration: Int = Toast.LENGTH_LONG) {
    if (BuildConfig.DEBUG) {
        Toast.makeText(this, msg, duration).show()
    }
}

fun ViewGroup.gone() {
    this.visibility = View.GONE
}

fun ViewGroup.visible() {
    this.visibility = View.VISIBLE
}

//重启应用
fun Context.restartApp() {
    val mIntent = packageManager.getLaunchIntentForPackage(packageName)?.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
    startActivity(mIntent)
    //杀掉以前进程
    android.os.Process.killProcess(android.os.Process.myPid())
}
